package com;


import java.io.IOException;

import android.os.RemoteException;

import com.android.uiautomator.core.Configurator;
import com.android.uiautomator.core.UiDevice;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.db.InitPro;
import com.db.TxtHelper;
import com.db.TxtHelper2;

public class UIautomatorTest extends UiAutomatorTestCase {
//	private String yanjiu = "软件测试研究会";
//	private String ceshi = "广州软件测试";
//	private String serverIP = "192.168.0.32";
	int copyType = 0;//copyType： 1图灵；0直接复读
	int isQQ = 0;//是否复读图片
	int isCopy2 = 0; //是否第2次才复读
	int isGuaji = 0;
	
	
	
	
	public void testDemo() throws UiObjectNotFoundException, RemoteException,
			IOException {
		//initChat();
		
		TxtHelper2 txtHelper = new TxtHelper2();
		txtHelper.initProc();
		InitPro initPro = txtHelper.getIniPro();
		
		if (initPro.getIsGuaji()==0) {
			if(initPro.getIsQQ()==1){
				System.out.println("isQQ==1qq");
				new CopyJi2().fudu(initPro.getChat1(), initPro.getChat2(), initPro.getServerIP(), initPro.getCopyType(), 
						initPro.getIsQQ(), initPro.getIsCopy2(),initPro.getIsLite());
			}else {
				System.out.println("isQQ==0weixin");
				new CopyJiWeixin().fudu(initPro.getChat1(), initPro.getChat2(), initPro.getServerIP(), initPro.getCopyType(), 
						initPro.getIsQQ(), initPro.getIsCopy2(),initPro.getIsLite());
			}
			
		}else {
			sleep(10000);
			guaJi();
		}
		
		//new CopyJi().fudu2(yanjiu,ceshi,serverIP,copyType,isImg,isCopy2);
	}
	
	void guaJi(){
		//UiDevice device = getUiDevice();
		Configurator.getInstance().setActionAcknowledgmentTimeout(0);
		System.out.println("   a   a   "+Configurator.getInstance().getActionAcknowledgmentTimeout());
		while(true){
			//UiDevice.getInstance().click(501, 910);
			//UiDevice.getInstance().click(502, 920);
			UiDevice.getInstance().click(503, 930);
			/*UiDevice.getInstance().click(504, 940);
			UiDevice.getInstance().click(505, 950);
			UiDevice.getInstance().click(506, 960);*/
		}
	}
	
	public void quicklyClick(int num,int x,int y) {
		long actionTimeout=Configurator.getInstance().getActionAcknowledgmentTimeout();
		Configurator.getInstance().setActionAcknowledgmentTimeout(0);
		for(int i=0;i<num;i++){
		//System.out.println("击。。。。。。。。。。。");
		UiDevice.getInstance().click(x, y); 
		}
		Configurator.getInstance().setActionAcknowledgmentTimeout(actionTimeout);
		}
	
	void isAPP(){
		if (getUiDevice().getCurrentPackageName().equals("com.miui.home")) {
			sleep(20000);
			isAPP();
		}
	}
	
	
}
